/**
 *@auther: tang
 *@Date: 2021-02-23
 *Project: p2pPlatformSys
 *Lang: TypeScript
 */
import { Controller } from 'egg';
class LogsController extends Controller {
  async logAdd(params:{
    msg:string,
    type:number,
    bsType:number,
    date:string
  }) {
    const { ctx } = this;
    ctx.logger.info('正在写入日志');
    console.log('正在写入日志');
    const result:any = await ctx.service.logs.add(params).catch(() => {
      ctx.body = {
        code: 502,
        msg: '添加失败，服务器异常,请联系管理员',
      };
    });
    console.log(result);
    if (result.id) {
      ctx.body = {
        code: 200,
        msg: '添加成功',
        row: result,
      };
    } else {
      ctx.body = {
        code: 400,
        msg: '添加失败，服务器异常',
      };
    }
  }
}

export default LogsController;
